/*
 * @Descripttion: 
 * @version: 
 * @Author: wtzhang
 * @Date: 2021-05-24 15:59:17
 * @LastEditors: wtzhang
 * @LastEditTime: 2021-05-25 09:07:59
 */

// 引入依赖
const mongoose = require('mongoose')
// 连接数据库
mongoose.connect('mongodb://localhost:27017', {
  useNewUrlParser: true,
  useUnifiedTopology: true
})

// 设计文档（表）结构
let studentSchema = mongoose.Schema({
  name: {
    type: String,
    required: true
  },
  gender: {
    type: String,
    require: true
  },
  age: {
    type: Number,
    required: true
  },
  hobbies: {
    type: String,
    required: true
  }
})

// 注册实例 model
module.exports = mongoose.model('Student', studentSchema)